from django.db import models

# Create your models here.


from django.db import models

# 院内
# 职称模型类
class TitleModel(models.Model):
    tname = models.CharField(max_length=50, verbose_name='职称名称')

    def __str__(self):
        return self.tname

    class Meta:
        db_table = 'title'

# 院内
# 专业方向模型类
class MajorModel(models.Model):
    mname = models.CharField(max_length=50, verbose_name='专业方向名称')

    def __str__(self):
        return self.mname

    class Meta:
        db_table = 'major'

# 院内
# 科室模型类
class DepartmentModel(models.Model):
    dname = models.CharField(max_length=50, verbose_name='科室名称')

    def __str__(self):
        return self.dname

    class Meta:
        db_table = 'department'

# 院内
# 次专业方向模型类
class SubMajorModel(models.Model):
    sname = models.CharField(max_length=50, verbose_name='次专业方向名称')

    def __str__(self):
        return self.sname

    class Meta:
        db_table = 'submajor'

# 院内
# 医生模型类，通过外键关联其他模型
class DoctorModel(models.Model):
    name = models.CharField(max_length=50, verbose_name='姓名')
    title = models.ForeignKey(TitleModel, on_delete=models.CASCADE, verbose_name='职称')
    major = models.ForeignKey(MajorModel, on_delete=models.CASCADE, verbose_name='专业方向')
    department = models.ForeignKey(DepartmentModel, on_delete=models.CASCADE, verbose_name='科室')
    sub_major = models.ForeignKey(SubMajorModel, on_delete=models.CASCADE, verbose_name='次专业方向')
    sort = models.IntegerField(verbose_name='医生排序', default=0)
    real_appointment = models.IntegerField(verbose_name='真实挂号量', default=0)
    virtual_appointment = models.IntegerField(verbose_name='虚拟挂号量', default=0)
    avatar = models.ImageField(upload_to='upload/', null=True, blank=True, verbose_name='医生头像')

    expertise = models.CharField(max_length=50,verbose_name='擅长项目')
    introduction = models.CharField(max_length=50, verbose_name='医生简介')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'doctor'


# 会诊状态
class StatusModel(models.Model):
    sname = models.CharField(max_length=50, verbose_name='状态名称')

    def __str__(self):
        return self.sname

    class Meta:
        db_table = 'status'

# 远程会诊
class RemoteConsultationModel(models.Model):
    avatar = models.ImageField(upload_to='upload/', null=True, blank=True, verbose_name='头像')
    name = models.CharField(max_length=50, verbose_name='姓名')
    major = models.ForeignKey(MajorModel, on_delete=models.CASCADE, verbose_name='专业方向')
    title = models.ForeignKey(TitleModel, on_delete=models.CASCADE, verbose_name='职称')
    expertise = models.TextField(verbose_name='擅长')
    is_online = models.CharField(max_length=20, verbose_name='在/离线')
    county_code = models.CharField(max_length=6, verbose_name='县（编号）')
    consultation_time = models.DateField(verbose_name='会诊时间')

    faqi = models.CharField(max_length=50, verbose_name='发起/接收')

    consultation_status = models.ForeignKey(StatusModel, on_delete=models.CASCADE, verbose_name='问诊状态')
    consultation_length = models.CharField(max_length=50, verbose_name='会诊时长')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'consultation'


class RemoteConsultationModel1(models.Model):
    remoteConsultationModel = models.ForeignKey(RemoteConsultationModel, on_delete=models.CASCADE, verbose_name='远程会诊')

    def __str__(self):
        return self.remoteConsultationModel.name

    class Meta:
        db_table = 'consultation1'



